******************
**  MAIN PAPER  ** 
******************

* Use Beck et al. (1998) BTSCS STATA Utility to create Carter & Signorino (2010) cubic polynomials of time
* Available at: https://www.prio.org/Data/Stata-Tools/

btscs attackyn_sp date gid, g(allpeacemos)
gen allpeacemos2 = allpeacemos^2
gen allpeacemos3 = allpeacemos^3

btscs softyn_sp date gid, g(softpeacemos)
gen softpeacemos2 = softpeacemos^2
gen softpeacemos3 = softpeacemos^3

btscs civyn_sp date gid, g(civpeacemos)
gen civpeacemos2 = civpeacemos^2
gen civpeacemos3 = civpeacemos^3

btscs est date gid, g(estmos)
gen estmos2 = estmos^2
gen estmos3 = estmos^3

** Table 1: Incidence of terrorism **

* Model 1 *
logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 2 * 
logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 3 * 
logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 4 * 
logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 5 * 
logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

* Model 6 * 
logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

** Table 2: Probability Changes for Table 1 **

* Model 1 *
logit attackyn_sp l.(i.est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

sum (L.est L.pk_duration_ccode L.logmountains_mean L.logbdist1 L.ttime_log L.logcapdist L.logipop_gpw_sum L.lognlights_calib_mean L.civconf splag_attackyn_sp) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.pk_duration_ccode = (23.10204 57.41146)) atmeans
margins, at(L.logmountains_mean = (-6.67944 -3.204585)) atmeans
margins, at(L.logbdist1 = (4.807902 5.985491)) atmeans
margins, at(L.ttime_log = (6.17413 6.8051537)) atmeans
margins, at(L.logcapdist = (6.410136 7.1452775)) atmeans
margins, at(L.logipop_gpw_sum = (9.999313 11.339538)) atmeans
margins, at(L.lognlights_calib_mean = (-4.061696 -2.151426)) atmeans
margins, at(L.splag_attackyn_sp = (.0012759 .0169083)) atmeans

* Model 2 *
logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

sum (L.pk_duration_ccode L.logcapdist L.logipop_gpw_sum L.lognlights_calib_mean L.logpolicepc1000 splag_attackyn_sp) if e(sample)==1, d

margins, atmeans
margins, dydx (L.civconf) atmeans
margins, at(L.pk_duration_ccode = (18.77143 53.40101)) atmeans
margins, at(L.logpolicepc1000 = (-9.977331 -8.389432)) atmeans
margins, at(L.logcapdist = (6.365033 7.1228261)) atmeans
margins, at(L.logipop_gpw_sum = (9.827751 11.337777)) atmeans
margins, at(L.lognlights_calib_mean = (-3.958567 -2.14566)) atmeans
margins, at(L.splag_attackyn_sp = (.0014496 .0182125)) atmeans

* Model 3 *
logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

sum (L.est L.pk_duration_ccode L.logmountains_mean L.logbdist1 L.ttime_log L.logcapdist L.logipop_gpw_sum L.lognlights_calib_mean L.civconf splag_softyn_sp) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.pk_duration_ccode = (23.10204 57.41146)) atmeans
margins, at(L.logmountains_mean = (-6.67944 -3.204585)) atmeans
margins, at(L.logbdist1 = (4.807902 5.985491)) atmeans
margins, at(L.ttime_log = (6.17413 6.8051537)) atmeans
margins, at(L.logcapdist = (6.410136 7.1452775)) atmeans
margins, at(L.logipop_gpw_sum = (9.999313 11.339538)) atmeans
margins, at(L.lognlights_calib_mean = (-4.061696 -2.151426)) atmeans
margins, at(L.splag_softyn_sp = (.0008662 .0132304)) atmeans

* Model 4 *
logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

sum (L.pk_duration_ccode L.logpolicepc1000 L.logbdist1 L.logcapdist L.logipop_gpw_sum L.lognlights_calib_mean L.splag_softyn_sp) if e(sample)==1, d

margins, atmeans
margins, dydx (L.civconf) atmeans
margins, at(L.pk_duration_ccode = (18.77143 53.40101)) atmeans
margins, at(L.logpolicepc1000 = (-9.977331 -8.389432)) atmeans
margins, at(L.logbdist1 = (4.771556 5.959478)) atmeans
margins, at(L.logcapdist = (6.365033 7.1228261)) atmeans
margins, at(L.logipop_gpw_sum = (9.827751 11.337777)) atmeans
margins, at(L.lognlights_calib_mean = (-3.958567 -2.14566)) atmeans
margins, at(L.splag_softyn_sp = (.0009264 .0139213)) atmeans

* Model 5 *
logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

sum (L.est L.pk_duration_ccode L.logmountains_mean L.logcapdist L.logipop_gpw_sum L.lognlights_calib_mean L.civconf splag_civyn_sp) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.pk_duration_ccode = (23.10204 57.41146)) atmeans
margins, at(L.logmountains_mean = (-6.67944 -3.204585)) atmeans
margins, at(L.logcapdist = (6.410136 7.1452775)) atmeans
margins, at(L.logipop_gpw_sum = (9.999313 11.339538)) atmeans
margins, at(L.lognlights_calib_mean = (-4.061696 -2.151426)) atmeans
margins, at(L.splag_civyn_sp = (.0006076 .0106587)) atmeans

* Model 6 *
logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

sum (L.est L.pk_duration_ccode L.logpolicepc1000 L.logmountains_mean L.logbdist1 L.logcapdist L.logipop_gpw_sum L.lognlights_calib_mean L.civconf L.splag_civyn_sp) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.pk_duration_ccode = (18.77143 53.40101)) atmeans
margins, at(L.logpolicepc1000 = (-9.977331 -8.389432)) atmeans
margins, at(L.logmountains_mean = (-6.35873 -2.734811)) atmeans
margins, at(L.logbdist1 = (4.771556 5.959478)) atmeans
margins, at(L.logcapdist = (6.365033 7.1228261)) atmeans
margins, at(L.logipop_gpw_sum = (9.827751 11.337777)) atmeans
margins, at(L.lognlights_calib_mean = (-3.958567 -2.14566)) atmeans
margins, at(L.splag_civyn_sp = (.000578 .0105482)) atmeans

** Table 3: Determinants of subnational peacekeeping deployment ** 

* Model 1 *
logit est attackyn_sp_3mo l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid estmos estmos2 estmos3) if date>383, cl(gid)

* Model 2 *
logit est softyn_sp_3mo l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid estmos estmos2 estmos3) if date>383, cl(gid)

* Model 3 *
logit est civyn_sp_3mo l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid estmos estmos2 estmos3) if date>383, cl(gid)

** Table 4: Incidence of terrorism, matching sample **

* Model 1 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo if year<2007, out(attackyn_sp)

pstest angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, both t(pk_presence_gid) graph

logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 2 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, out(attackyn_sp)

pstest angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, both t(pk_presence_gid) graph 

logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 3 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo if year<2007, out(softyn_sp)

pstest angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, both t(pk_presence_gid) graph

logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

* Model 4 * 
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, out(softyn_sp)

pstest angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, both t(pk_presence_gid) graph

logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

* Model 5 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo if year<2007, out(civyn_sp)

pstest angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, both t(pk_presence_gid) graph

logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

* Model 6 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, out(civyn_sp)

pstest angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, both t(pk_presence_gid) graph

logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

** Table 5: Probability Changes for Table 4 **

* Model 1
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo if year<2007, out(attackyn_sp)

logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

sum (L.est L.logmountains_mean L.logbdist1 L.ttime_log L.lognlights_calib_mean L.civconf) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.logmountains_mean = (-4.913133 -0.971941)) atmeans
margins, at(L.logbdist1 = (4.411495 6.032957)) atmeans
margins, at(L.ttime_log = (5.582249 6.2894256)) atmeans
margins, at(L.lognlights_calib_mean = (-3.475014 -2.6390949)) atmeans

* Model 2
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, out(attackyn_sp)

logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

sum (L.civconf L.logtroopspc1000 L.logpolicepc1000 L.logcapdist) if e(sample)==1, d

margins, atmeans
margins, dydx (L.civconf) atmeans
margins, at(L.logtroopspc1000 = (-9.078235 -6.534471)) atmeans
margins, at(L.logpolicepc1000 = (-11.13717 -9.14041)) atmeans
margins, at(L.logcapdist = (5.872223 7.271999)) atmeans

* Model 3
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo if year<2007, out(softyn_sp)

logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

sum (L.est L.pk_duration_ccode L.logPKODEPstrength L.logmountains_mean L.logbdist1 L.civconf) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.pk_duration_ccode = (61.25493 93.80432)) atmeans
margins, at(L.logPKODEPstrength = (-1.410614 3.094247)) atmeans
margins, at(L.logmountains_mean = (-4.912139 -0.974607)) atmeans
margins, at(L.logbdist1 = (4.416732 6.033766)) atmeans

* Model 4
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, out(softyn_sp)

logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

sum (L.est L.pk_duration_ccode L.logmountains_mean L.logbdist1 L.civconf) if e(sample)==1, d

margins, atmeans
margins, dydx (L.est L.civconf) atmeans
margins, at(L.pk_duration_ccode = (55.78702 90.54891)) atmeans
margins, at(L.logmountains_mean = (-4.920164 -0.935784)) atmeans
margins, at(L.logbdist1 = (4.382635 5.974236)) atmeans

* Model 5
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo if year<2007, out(civyn_sp)

logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

sum (L.pk_duration_gid L.pk_duration_ccode L.logmountains_mean) if e(sample)==1, d

margins, atmeans
margins, at(L.pk_duration_gid = (8.615005 28.897005)) atmeans
margins, at(L.pk_duration_ccode = (61.47779 93.375)) atmeans
margins, at(L.logmountains_mean = (-4.900873 -0.963362)) atmeans

* Model 6
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, out(civyn_sp)

logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

sum (L.pk_duration_gid L.pk_duration_ccode L.logobspc1000 L.logipop_gpw_sum) if e(sample)==1, d

margins, atmeans
margins, at(L.pk_duration_gid = (8.843076 28.863986)) atmeans
margins, at(L.pk_duration_ccode = (56.18346 90.85056)) atmeans
margins, at(L.logobspc1000 = (-11.00153 -9.75922)) atmeans
margins, at(L.logipop_gpw_sum = (11.5001 13.00957)) atmeans

********************************************
**  APPENDIX - All Tables Except A10-A13  **
********************************************

* Summary Statistics
sum l.(attackyn_sp softyn_sp civyn_sp est pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength logtroopspc1000 logpolicepc1000 logobspc1000 log_notroopspercap1000 splag_attackyn_sp splag_softyn_sp splag_civyn_sp splag_pk_presence_gid) 

*** Robustness Tests Using Fixed Effects ***

** Table A3: Incidence of terrorism (1992-2006), logistic regression, cell-level fixed effects **

* Model 1
xtlogit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), fe

* Model 2
xtlogit softyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), fe

* Model 3
xtlogit civyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), fe

** Table A4: Incidence of terrorism (1992-2006), logistic regression, country-level fixed effects **

* Model 1
logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid i.ccode allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 2
logit softyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid i.ccode softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 3
logit civyn_sp l.(est pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid i.ccode civpeacemos civpeacemos2 civpeacemos3), cl(gid)

*** Alternative Coding of the Dependent Variable ***

** Table A5: Number of terrorist attacks per cell (1992-2006), zero-inflated negative binomial **
tsset gid date, monthly
gen lagest = l.est
gen lagpk_duration_gid = l.pk_duration_gid
gen lagpk_duration_ccode = l.pk_duration_ccode
gen laglogPKODEPstrength = l.logPKODEPstrength
gen laglogtroopspc1000 = l.logtroopspc1000
gen laglogpolicepc1000 = l.logpolicepc1000
gen laglogobspc1000 = l.logobspc1000
gen laglogmountains_mean = l.logmountains_mean
gen laglogbdist1 = l.logbdist1
gen lagttime_log = l.ttime_log
gen laglogcapdist = l.logcapdist
gen laglogipop_gpw_sum = l.logipop_gpw_sum
gen laglognlights_calib_mean = l.lognlights_calib_mean
gen lagcivconf = l.civconf
gen lagsplag_attackyn_sp = l.splag_attackyn_sp
gen lagsplag_softyn_sp = l.splag_softyn_sp
gen lagsplag_civyn_sp = l.splag_civyn_sp
gen lagsplag_pk_presence_gid = l.splag_pk_presence_gid
gen lagallpeacemos = l.allpeacemos
gen lagallpeacemos2 = l.allpeacemos2
gen lagallpeacemos3 = l.allpeacemos3
gen lagsoftpeacemos = l.softpeacemos
gen lagsoftpeacemos2 = l.softpeacemos2
gen lagsoftpeacemos3 = l.softpeacemos3
gen lagcivpeacemos = l.civpeacemos
gen lagcivpeacemos2 = l.civpeacemos2
gen lagcivpeacemos3 = l.civpeacemos3

* Model 1 * 
zinb attack_sp lagest lagpk_duration_gid lagpk_duration_ccode laglogPKODEPstrength laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf lagsplag_attackyn_sp lagsplag_pk_presence_gid lagallpeacemos lagallpeacemos2 lagallpeacemos3, inflate (laglognlights_calib_mean laglogipop_gpw_sum) vce (cluster gid)

* Model 2 *
zinb attack_sp lagest lagpk_duration_gid lagpk_duration_ccode laglogtroopspc1000 laglogpolicepc1000 laglogobspc1000 laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf lagsplag_attackyn_sp lagsplag_pk_presence_gid lagallpeacemos lagallpeacemos2 lagallpeacemos3, inflate (laglognlights_calib_mean laglogipop_gpw_sum) vce (cluster gid)

* Model 3 *
zinb soft_sp lagest lagpk_duration_gid lagpk_duration_ccode laglogPKODEPstrength laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf lagsplag_softyn_sp lagsplag_pk_presence_gid lagsoftpeacemos lagsoftpeacemos2 lagsoftpeacemos3, inflate (laglognlights_calib_mean laglogipop_gpw_sum) vce (cluster gid)

* Model 4 *
zinb soft_sp lagest lagpk_duration_gid lagpk_duration_ccode laglogtroopspc1000 laglogpolicepc1000 laglogobspc1000 laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf lagsplag_softyn_sp lagsplag_pk_presence_gid lagsoftpeacemos lagsoftpeacemos2 lagsoftpeacemos3, inflate (laglognlights_calib_mean laglogipop_gpw_sum) vce (cluster gid)

* Model 5 *
zinb civ_sp lagest lagpk_duration_gid lagpk_duration_ccode laglogPKODEPstrength laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf lagsplag_civyn_sp lagsplag_pk_presence_gid lagcivpeacemos lagcivpeacemos2 lagcivpeacemos3, inflate (laglognlights_calib_mean laglogipop_gpw_sum) vce (cluster gid)

* Model 6 *
zinb civ_sp lagest lagpk_duration_gid lagpk_duration_ccode laglogtroopspc1000 laglogpolicepc1000 laglogobspc1000 laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf  lagsplag_civyn_sp lagsplag_pk_presence_gid lagcivpeacemos lagcivpeacemos2 lagcivpeacemos3, inflate (laglognlights_calib_mean laglogipop_gpw_sum) vce (cluster gid)

drop lagest lagpk_duration_gid lagpk_duration_ccode laglogPKODEPstrength laglogtroopspc1000 laglogpolicepc1000 laglogobspc1000 laglogmountains_mean laglogbdist1 lagttime_log laglogcapdist laglogipop_gpw_sum laglognlights_calib_mean lagcivconf lagsplag_attackyn_sp lagsplag_softyn_sp lagsplag_civyn_sp lagsplag_pk_presence_gid lagallpeacemos lagallpeacemos2 lagallpeacemos3 lagsoftpeacemos lagsoftpeacemos2 lagsoftpeacemos3 lagcivpeacemos lagcivpeacemos2 lagcivpeacemos3 

*** Running a simplified analysis of dichotomous UN presence rather than UN escalation and mission duration ***

** Table A6: Incidence of terrorism (1992-2006), logistic regression **

* Model 1 *
logit attackyn_sp l.(pk_presence_gid pk_presence_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos  allpeacemos2 allpeacemos3), cl(gid)

* Model 2 * 
logit attackyn_sp l.(pk_presence_gid pk_presence_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 3 *
logit softyn_sp l.(pk_presence_gid pk_presence_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 4 *
logit softyn_sp l.(pk_presence_gid pk_presence_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 5 *
logit civyn_sp l.(pk_presence_gid pk_presence_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) if date>383, cl(gid)

* Model 6 *
logit civyn_sp l.(pk_presence_gid pk_presence_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

** Table A7: Incidence of terrorism (1992-2006), logistic regression, matching sample **

* Model 1 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo if year<2007, out(attackyn_sp)

pstest angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo if year<2007, both t(pk_presence_gid) graph 

logit attackyn_sp l.(pk_presence_gid pk_presence_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 2 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, out(attackyn_sp)

pstest angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, both t(pk_presence_gid) graph 

logit attackyn_sp l.(pk_presence_gid pk_presence_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 3 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, out(softyn_sp)

pstest angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo if year<2007, both t(pk_presence_gid) graph

logit softyn_sp l.(pk_presence_gid pk_presence_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3)[fweight=_weight], cl(gid)

* Model 4 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, out(softyn_sp)

pstest angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, both t(pk_presence_gid) graph

logit softyn_sp l.(pk_presence_gid pk_presence_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

* Model 5 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, out(civyn_sp)

pstest angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo if year<2007, both t(pk_presence_gid) graph

logit civyn_sp l.(pk_presence_gid pk_presence_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) if date>383 [fweight=_weight], cl(gid)

* Model 6 *
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, out(civyn_sp)

pstest angola burundi car drc ivorycoast liberia mozambique namibia rwanda sierraleone somalia sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, both t(pk_presence_gid) graph

logit civyn_sp l.(pk_presence_gid pk_presence_ccode logtroopspc1000 logpolicepc1000 logobspc1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

*** Alternative Measures of Local Troop Numbers ***

* Table A8: Incidence of terrorism (1992-2006), logistic regression

* Model 1 - All Attacks *
logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode log_notroopspercap1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 2 - Soft Target Attacks *
logit softyn_sp l.(est pk_duration_gid pk_duration_ccode log_notroopspercap1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 3 - Civilian Attacks *
logit civyn_sp l.(est pk_duration_gid pk_duration_ccode log_notroopspercap1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

** Table A9: Incidence of terrorism (1992-2006), logistic regression, matching sample **

* Model 1 - All Attacks
psmatch2 pk_presence_gid burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo if year>1999 & year<2009, out(attackyn_sp)

pstest burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log attackyn_sp_6mo, both t(pk_presence_gid) graph

logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode log_notroopspercap1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight], cl(gid)

* Model 2 - Soft Target Attacks *
psmatch2 pk_presence_gid burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo if year>1999 & year<2009, out(softyn_sp)

pstest burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log softyn_sp_6mo, both t(pk_presence_gid) graph

logit softyn_sp l.(est pk_duration_gid pk_duration_ccode log_notroopspercap1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3) [fweight=_weight], cl(gid)

* Model 3 - Civilian Attacks *
psmatch2 pk_presence_gid burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo if year>1999 & year<2009, out(civyn_sp)

pstest burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum logmountains_mean ttime_log civyn_sp_6mo, both t(pk_presence_gid) graph

logit civyn_sp l.(est pk_duration_gid pk_duration_ccode log_notroopspercap1000 logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3) [fweight=_weight], cl(gid)

** Figure A1: Comparison of ROC Curves Between Table 4, Model 1 and Baseline Model **
psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum laglogmountains_mean ttime_log attackyn_sp_6mo if year<2007, out(attackyn_sp)

logit attackyn_sp l.(est pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf logPKODEPstrength splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight] if year<2007, cl(gid)

predict p1 if e(sample), pr
lroc

psmatch2 pk_presence_gid angola burundi car drc ivorycoast liberia sierraleone sudan logipop_gpw_sum laglogmountains_mean ttime_log attackyn_sp_6mo if year<2007, out(attackyn_sp)

logit attackyn_sp l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf logPKODEPstrength splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3) [fweight=_weight] if year<2007, cl(gid)

predict p2 if e(sample), pr
lroc

roccomp attackyn_sp p1 p2
roccomp attackyn_sp p1 p2, graph 
drop p1 p2

*** Analysis Disaggregating UN Expansion Independent Variable ***

** Table A14: Incidence of Terrorism (1992-2016), logistic regression, all attacks **

* Model 1
logit attackyn_sp l.(PKOHQstart pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 2
logit attackyn_sp l.(expPKO pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 3
logit attackyn_sp l.(PKORegOff pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 4
logit attackyn_sp l.(IncPer pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

* Model 5
logit attackyn_sp l.(Reopen pk_duration_gid pk_duration_ccode logPKODEPstrength logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf splag_attackyn_sp splag_pk_presence_gid allpeacemos allpeacemos2 allpeacemos3), cl(gid)

** Table A15: Incidence of Terrorism (1992-2016), logistic regression, soft target attacks

* Model 1
logit softyn_sp l.(PKOHQstart pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 2
logit softyn_sp l.(PKORegOff pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 3
logit softyn_sp l.(IncPer pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

* Model 4
logit softyn_sp l.(Reopen pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_softyn_sp splag_pk_presence_gid softpeacemos softpeacemos2 softpeacemos3), cl(gid)

** Table A16: Incidence of Terrorism (1992-2016), logistic regression, civilian attacks

* Model 1
logit civyn_sp l.(PKOHQstart pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

* Model 2
logit civyn_sp l.(PKORegOff pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

* Model 3
logit civyn_sp l.(IncPer pk_duration_gid pk_duration_ccode logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean i.civconf logPKODEPstrength splag_civyn_sp splag_pk_presence_gid civpeacemos civpeacemos2 civpeacemos3), cl(gid)

** Table A17: Determinants of Peacekeeper Presence ** 

* Model 1 *
logit est attackyn_sp_6mo l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_attackyn_sp splag_pk_presence_gid estmos estmos2 estmos3) if date>383, cl(gid)

* Model 2 *
logit est softyn_sp_6mo l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_softyn_sp splag_pk_presence_gid estmos estmos2 estmos3) if date>383, cl(gid)

* Model 3 *
logit est civyn_sp_6mo l.(logmountains_mean logbdist1 ttime_log logcapdist logipop_gpw_sum lognlights_calib_mean civconf splag_civyn_sp splag_pk_presence_gid estmos estmos2 estmos3) if date>383, cl(gid)